
package com.scjyzr.mysweeper;

import com.umeng.analytics.MobclickAgent;

import android.content.Context;
import android.util.Log;

public class StatisiticUtil {
    private static final String TAG = "StatisiticUtil";

    /**
     * 是否开启功能统计
     */
    private static final boolean IS_STATISTICS = true;

    public interface StatisticKey {
        
        
        String OPEN_GAME="open_game";//打开游戏
        String START_GAME="start_game";//开始游戏
        String SELECT_DIFF="select_diff";//选择游戏难度
        String FRESH_GAME="fresh_game";//刷新游戏
        String WIN_GAME="win_game";//赢得游戏
        String GAME_OVER="game_over";//踩到地雷
        String SELECT_FLAG="select_flag";//选择插旗
        
        String SELECT_DIFF_OK="select_diff_ok";//变化游戏难度
        
        String HIS_LEVEL="his_level";//历史记录

    }

    /**
     * 功能统计
     * 
     * @param context
     * @param statisiticKey StatisiticKey中的资源
     */
    public static void functiontSatistics(Context context, String statisiticKey) {
        if (IS_STATISTICS) {
            try {
                MobclickAgent.onEvent(context, statisiticKey);
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }
        }
    }

    /**
     * 统计页面启动
     * 
     * @param context
     */
    public static void onResume(Context context) {
        if (IS_STATISTICS) {
            try {
                MobclickAgent.onResume(context);
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }
        }
    }

    /**
     * 统计页面关闭
     * 
     * @param context
     */
    public static void onPause(Context context) {
        if (IS_STATISTICS) {
            try {
                MobclickAgent.onPause(context);
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }
        }
    }

    /**
     * 统计错误
     * 
     * @param context
     */
    public static void onError(Context context) {
        if (IS_STATISTICS) {
            try {
                MobclickAgent.onError(context);
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }
        }
    }

}
